﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace wars2
{
    internal class Converter
    {
        public double convertToDouble(string inputVariable)
        {
            double doubleResoult;
            inputVariable = inputVariable.Replace(".",",");
            bool isDouble = Double.TryParse(inputVariable, out doubleResoult);
            if (isDouble)
            {
                return doubleResoult;
            }
            else
            {
                Console.WriteLine("\nIncorrect value, try another");
                inputVariable = Console.ReadLine();
                return convertToDouble(inputVariable);
            }

        }
        public char convertMathSign(string mathSignString)
        {
            char mathSign;
            bool isChar = char.TryParse(mathSignString, out mathSign);
            if (isChar)
            {
                switch (mathSign)
                {
                    case '+':
                        mathSign = '+';
                        return mathSign;
                    case '-':
                        mathSign = '-';
                        return mathSign;
                    case '*':
                        mathSign = '*';
                        return mathSign;
                    case '/':
                        mathSign = '/';
                        return mathSign;
                    default:
                        Console.WriteLine("\nincorrect Value, try again");
                        return convertMathSign(Console.ReadLine());
                }
            }
            else
                {
                    Console.WriteLine("\nincorrect Value, try again");
                    return convertMathSign(Console.ReadLine());
                }
        }
    }
}
